/******************************************************************************* 
 * Copyright (c) 2002 Boris Pruessmann and others.
 * All rights reserved.   This program and the accompanying materials
 * are made available under the terms of the Common Public License v0.5
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/cpl-v05.html
 * 
 * Contributors:
 *    Boris Pruessmann - Initial implementation
 ******************************************************************************/
package net.sourceforge.perforce.internal.api;

import java.io.InputStream;

import net.sourceforge.perforce.core.api.IResolveResult;
import net.sourceforge.perforce.core.internal.api.Resolve;

/**
  * @author  <a href="mailto:bpruessmann@users.sourceforge.net">Boris Pruessmann</a>
  * @version $Revision: 210 $ 
  */
public class ResolveTest extends ClientUserTestCase
{
	// --------------------------------------------------------------------------- Private Variables
	
	/** Stores the Resolve object. */
	private Resolve clientUser;
	
	// ------------------------------------------------------------------------- Public Constructors
	
	/** Constructor for ResolveTest.
	  *
	  * @param name the name of the test. 
	  */
	public ResolveTest(String name)
	{
		super(name);
	}
	
	// ------------------------------------------------------------------------------ Public Methods
	
	public void testResolve1()
		throws Exception
	{
		InputStream script = getClass().getResourceAsStream("resolve_test1.xml");
		executeScript(script, clientUser);
		
		IResolveResult[] result = clientUser.getResult();
		assertEquals(2, result.length);
		assertEquals(
			"c:\\Sources\\Perforce\\p4eclipse\\net.sourceforge.perforce.api\\.cvsignore",
			result[0].getLocalFilename());
		assertEquals(
			"//p4eclipse/net.sourceforge.perforce.api/.cvsignore",
			result[0].getDepotFilename());
		assertEquals(4, result[0].getRevision().intValue());
		assertFalse(result[0].isSkipped());
		
		assertEquals(
			"c:\\Sources\\Perforce\\p4eclipse\\net.sourceforge.perforce.api\\.cvsignore2",
			result[1].getLocalFilename());
		assertEquals(
			"//p4eclipse/net.sourceforge.perforce.api/.cvsignore2",
			result[1].getDepotFilename());
		assertEquals(3, result[1].getRevision().intValue());
		assertFalse(result[1].isSkipped());
	}
	
	public void testResolve2()
		throws Exception
	{
		InputStream script = getClass().getResourceAsStream("resolve_test2.xml");
		executeScript(script, clientUser);
		
		IResolveResult[] result = clientUser.getResult();
		assertEquals(1, result.length);
		assertEquals(
			"c:\\Sources\\Perforce\\p4eclipse\\net.sourceforge.perforce.api\\.cvsignore",
			result[0].getLocalFilename());
		assertEquals(
			"//p4eclipse/net.sourceforge.perforce.api/.cvsignore",
			result[0].getDepotFilename());
		assertEquals(4, result[0].getRevision().intValue());
		assertFalse(result[0].isSkipped());
	}
	
	public void testResolve3()
		throws Exception
	{
		InputStream script = getClass().getResourceAsStream("resolve_test3.xml");
		executeScript(script, clientUser);
		
		IResolveResult[] result = clientUser.getResult();
		assertEquals(1, result.length);
		assertEquals(
			"c:\\Sources\\Perforce\\p4eclipse\\net.sourceforge.perforce.api\\.cvsignore",
			result[0].getLocalFilename());
		assertEquals(
			"//p4eclipse/net.sourceforge.perforce.api/.cvsignore",
			result[0].getDepotFilename());
		assertEquals(4, result[0].getRevision().intValue());
		assertTrue(result[0].isSkipped());
	}
	
	public void testResolve4()
		throws Exception
	{
		InputStream script = getClass().getResourceAsStream("resolve_test4.xml");
		executeScript(script, clientUser);
		
		IResolveResult[] result = clientUser.getResult();
		assertEquals(1, result.length);
		assertEquals(
			"c:\\Sources\\Perforce\\p4eclipse\\net.sourceforge.perforce.api\\.cvsignore",
			result[0].getLocalFilename());
		assertEquals(
			"//p4eclipse/net.sourceforge.perforce.api/.cvsignore",
			result[0].getDepotFilename());
		assertEquals(4, result[0].getRevision().intValue());
		assertTrue(!result[0].isSkipped());
	}
	
	// --------------------------------------------------------------------------- Protected Methods 
	
	/** @see junit.framework.TestCase#setUp() */
	protected void setUp() 
		throws Exception 
	{
		super.setUp();
		
		clientUser = Resolve.newInstance();
	}
}
